home *** CD-ROM | disk | FTP | other *** search
/ MacWorld Secrets (4th Edition) / Mac Secrets CD 4th Ed.toast / Apple Advanced Technologies / Apple Speech Technologies 1.5 / PlainTalk Developer Info / Speech Recognition Manager SDK / SR Sample Code / IM SR Example / MyHandleSpeechDone.c < prev    next >
C/C++ Source or Header  |  1996-04-10  |  1KB  |  41 lines

  1. #include <SpeechRecognition.h>
  2. #include <AppleEvents.h>
  3.  
  4. extern void MyProcessRecognitionResult (SRRecognitionResult recResult);
  5.  
  6. pascal OSErr MyHandleSpeechDone (AppleEvent *theAEevt, AppleEvent *reply, long refcon);
  7.  
  8.  
  9. pascal OSErr MyHandleSpeechDone (AppleEvent *theAEevt, AppleEvent *reply, 
  10.                                                                     long refcon) 
  11. {
  12.     OSErr                     myErr = noErr;
  13.     long                     actualSize;
  14.     DescType                 actualType;
  15.     OSErr                     recStatus = noErr;
  16.     SRRecognitionResult     recResult; 
  17.     SRRecognizer             myRec;
  18.     
  19.     /* Get recognition result status and recognizer.         */
  20.     myErr = AEGetParamPtr (theAEevt, keySRSpeechStatus, typeShortInteger,
  21.                 &actualType, (Ptr) &recStatus, sizeof (recStatus), &actualSize);
  22.     if (!myErr) myErr = recStatus;
  23.     if (!myErr) {
  24.         myErr = AEGetParamPtr (theAEevt, keySRRecognizer, typeSRRecognizer, 
  25.                         &actualType, (Ptr) &myRec, sizeof (myRec), &actualSize);
  26.         
  27.         if (!myErr) {
  28.             myErr = AEGetParamPtr (theAEevt, keySRSpeechResult, typeSRSpeechResult, 
  29.                 &actualType, (Ptr)&recResult, sizeof(recResult), &actualSize);
  30.             if (!myErr) {
  31.                 /* Process the recognition result here.     */
  32.                 MyProcessRecognitionResult (recResult);
  33.                 
  34.                 /* Release the precessed result             */
  35.                 SRReleaseObject (recResult);
  36.             }
  37.         }
  38.     }
  39.  
  40.     return myErr;
  41. }